package org.example.spring_frist.Wbook;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

public class decoupling {

}

class car {
    wheel w;
    public car(int size) {
        w = new wheel(size);
    }
}

class wheel{
    int size;
    public wheel(int size) {
        this.size = size;
    }
}

@Component
class car1 {
    @Autowired
    wheel1 w;
}

@Component
class wheel1 {
    @Value("${wheel.size:20}")//从配置文件中读取size的值
    Integer size;
}


@Component
class A {
    public A a1() {
        System.out.println("a1");
        return new A();
    }

    public A a2() {
        System.out.println("a2");
        return new A();
    }
}







